package com.buss.common.util.sms;

import javax.servlet.http.HttpServletRequest;

import org.jweb.core.util.PropertiesUtil;

import com.buss.member.entity.GeneralUserEntity;

/**
 * @author wupan
 * 邮件内容模板
 *
 */
public class MailTemplets {
	
	/**
	 * 邮件发送内容
	 * @param util
	 * @param userEntity
	 * @param tsSmsEntity
	 * @param mailContentType
	 * @return
	 */
	public static String getMailContent(PropertiesUtil util, GeneralUserEntity userEntity, 
			TSSmsEntity tsSmsEntity, int mailContentType, HttpServletRequest request) {

		switch (mailContentType) {
	     case 0: 
	    	 return setMailContentJoin(util, userEntity, tsSmsEntity, request);
	     case 1: 
	    	 return setMailContentPwdReset(util, userEntity, tsSmsEntity, request);
	     case 2: 
	    	 return setMailContentPayNotify(util, userEntity, tsSmsEntity, request);
	   }
		return "";
	}
	
	/**
	 * join
	 */
	public static String setMailContentJoin(PropertiesUtil util, GeneralUserEntity userEntity, 
			TSSmsEntity tsSmsEntity, HttpServletRequest request) {
		//用户邮箱校验网址拼接 URL + 用户id
//		String url = util.readProperty("mail.url") +"join.do?id="+ userEntity.getId();
		String url = "http://"+request.getServerName()+"/"+util.readProperty("mail.url.user.join")+"?id="+ userEntity.getId();
//		System.out.println(url);
		String realname = userEntity.getRealname();
		if(!"".equals(realname)&&realname!=null){
			realname = realname+"，";
		}
		
		StringBuffer demo = new StringBuffer();
		demo.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">")  
        .append("<html>")
        .append("<head>")
        .append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">")
        .append("<title>成功企业家俱乐部</title>")
        .append("<style type=\"text/css\">")
        .append(".test{font-family:\"Microsoft Yahei\";font-size: 18px;color: red;}")
        .append("</style>")
        .append("</head>")
        .append("<body>")
        .append("<span class=\"test\">成功企业家俱乐部</span>")
        .append("<br />")
        .append("<hr />")
        .append("<span>"+realname+"你好！</span>")
        .append("<br />")
        .append("<span>点击下面链接，立即激活成功企业家俱乐部会员账号。</span>")
        .append("<br />")
        .append("<a href=\""+url+"\">"+url+"</a>")
        .append("<br />")
        .append("<hr />")
        .append("</body>")
        .append("</html>");
		return demo.toString();
	}
	
	/**
	 * PwdReset
	 */
	public static String setMailContentPwdReset(PropertiesUtil util, GeneralUserEntity userEntity, 
			TSSmsEntity tsSmsEntity, HttpServletRequest request) {
		//用户邮箱校验网址拼接 URL + 用户id
//		String url = util.readProperty("mail.url") +"pwdreset.do?id="+ userEntity.getId();
		String url = "http://"+request.getServerName()+"/"+util.readProperty("mail.url.user.pwd")+"?id="+ userEntity.getId();
//		System.out.println(url);
		String realname = userEntity.getRealname();
		if(!"".equals(realname)&&realname!=null){
			realname = realname+"，";
		}
		
		StringBuffer demo = new StringBuffer();
		demo.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">")  
        .append("<html>")
        .append("<head>")
        .append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">")
        .append("<title>成功企业家俱乐部</title>")
        .append("<style type=\"text/css\">")
        .append(".test{font-family:\"Microsoft Yahei\";font-size: 18px;color: red;}")
        .append("</style>")
        .append("</head>")
        .append("<body>")
        .append("<span class=\"test\">成功企业家俱乐部</span>")
        .append("<br />")
        .append("<hr />")
        .append("<span>"+realname+"你好！</span>")
        .append("<br />")
        .append("<span>请点击下面链接重置您的密码</span>")
        .append("<br />")
        .append("<a href=\""+url+"\">"+url+"</a>")
        .append("<br />")
        .append("<hr />")
        .append("</body>")
        .append("</html>");
		return demo.toString();
	}
	
	
	/**
	 * PayNotify
	 */
	public static String setMailContentPayNotify(PropertiesUtil util, GeneralUserEntity userEntity, 
			TSSmsEntity tsSmsEntity, HttpServletRequest request) {
		//用户邮箱校验网址拼接 URL + 用户id
//		String url = util.readProperty("mail.url") +"pwdreset.do?id="+ userEntity.getId();
//		String url = "http://"+request.getServerName()+"/"+util.readProperty("mail.url.pwd")+"?id="+ userEntity.getId();
//		System.out.println(url);
		String realname = userEntity.getRealname();
		if(!"".equals(realname)&&realname!=null){
			realname = realname+"，";
		}
		
		StringBuffer demo = new StringBuffer();
		demo.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">")  
        .append("<html>")
        .append("<head>")
        .append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">")
        .append("<title>成功企业家俱乐部</title>")
        .append("<style type=\"text/css\">")
        .append(".test{font-family:\"Microsoft Yahei\";font-size: 18px;color: red;}")
        .append("</style>")
        .append("</head>")
        .append("<body>")
        .append("<span class=\"test\">成功企业家俱乐部</span>")
        .append("<br />")
        .append("<hr />")
        .append("<span>"+realname+"你好！请缴纳会费</span>")
        .append("<br />")
//        .append("<span>请缴纳会费</span>")
//        .append("<br />")
//        .append("<a href=\""+url+"\">"+url+"</a>")
//        .append("<br />")
        .append("<hr />")
        .append("</body>")
        .append("</html>");
		return demo.toString();
	}
	
}
